package com.boco.fznq.home;

import com.boco.fznq.AppConstants;
import com.boco.fznq.network.HttpListener;
import com.boco.fznq.network.HttpUtils;
import com.culiu.core.presenter.BasePresenter;
import com.culiu.core.utils.debug.DebugLog;
import com.culiu.core.utils.notification.ToastUtils;

/**
 * Created by jiangcheng on 2016/12/13.
 */

public class HomePresenter extends BasePresenter<IHomeUI> {


    public void requestNewsData() {
        final String requestUrl = AppConstants.HOST + "api/index_news";
        HttpUtils.post(requestUrl, null, NewsBean.class, new HttpListener<NewsBean>() {
            @Override
            public void onResponse(NewsBean response) {
                if (response != null && response.isSuccess()
                        && response.getData() != null) {
                    getUi().showNewsData(response.getData());
                }
            }

            @Override
            public void onError(Exception e) {
                ToastUtils.showShort(getActivity(), "新闻请求失败");
            }
        });
    }
}
